describe('prepare', function() {
    describe('mix function', function() {
        var parent, parentFun, parentObj, parentVal, child, childFn, parentArr;
        beforeEach(function() {
            child = {}
            childFn = function() {}
            parentVal = "value"
            parentFun = function() {
                return this.val
            },
            parentArr = [1, 2, 3, 4]
            parentObj = {}
            parent = {
                val: parentVal,
                fun: parentFun,
                obj: parentObj,
                arr: parentArr
            }
        })
        describe('when deep is false', function() {
            it('it can get the parent function and values and objects', function() {

                jc.mix(child, parent)
                expect(child.val).toBeDefined()
                expect(child.fun).toBeDefined()
                expect(child.obj).toBeDefined()
                expect(child.val).toEqual(parentVal)
                expect(child.fun).toBe(parentFun)
                expect(child.obj).toBe(parentObj)
                expect(child.fun === parentFun).toBe(true)
                expect(child.arr).toBe(parentArr)

            })

        })
        describe('when deep is true', function() {
            it('it can get the parent function and values,object will be a new one', function() {

                jc.mix(true, child, parent)
                expect(child.val).toBeDefined()
                expect(child.fun).toBeDefined()
                expect(child.obj).toBeDefined()
                expect(child.val).toEqual(parentVal)
                expect(child.fun).toBe(parentFun)
                expect(child.obj).not.toBe(parentObj)
                expect(child.arr).not.toBe(parentArr)
                expect(child.fun === parentFun).toBe(true)


            })
        });
        it('can refer parent', function() {
            jc.mix(child, parent)
            expect(child.fun()).toEqual(parentVal)
        })
        it('the child can be function', function() {
            jc.mix(childFn, parent)
            expect(childFn.fun()).toEqual(parentVal)
        })



    })
    describe("dotPathVal", function() {
        it("can evaluate the right value according to the path", function() {
            var ob1 = {
                a: ""
            }
            dotPathVal(ob1, "a", "b")
            expect(ob1.a).toBe("b")
            var ob2 = {
                a: {
                    b: ""
                }
            }
            dotPathVal(ob2, "a.b", "b")
            expect(ob2.a.b).toBe("b")
        })
    })

    describe("arrPathRef", function() {
        it("should return an object with obj and ref attr", function() {
            var data3 = {
                elems: [{
                    data: 1,
                    isShow: true
                }, {
                    data: 2,
                    isShow: false
                }, {
                    data: 3,
                    isShow: true
                }]
            };
            var re = arrPathRef(data3, ["elems"])
            expect(re.obj).toBe(data3)
            expect(re.ref).toBe("elems")
        })
    })
    // describe("dotPathRef", function() {
    //     it(" can return the right thing", function() {
    //         var ob1 = {
    //             a: ""
    //         }

    //         var ob2 = {
    //             a: {
    //                 b: ""
    //             }
    //         }

    //         var re1 = dotPathRef(ob1, "a")
    //         expect(re1.obj).toBe(ob1)
    //         expect(re1.ref).toEqual("a")


    //         var re2 = dotPathRef(ob2, "a.b")
    //         expect(re2.obj).toBe(ob2.a)
    //         expect(re2.ref).toEqual("b")


    //     })
    //     it("can return the right thing of mix path", function() {
    //         // var path1=".a[0][0]"
    //         // var path2=".a[0].b"
    //         // var obj1={a:[[1]]}
    //         // expect()
    //     })
    // })
    describe("collectionPath", function() {
        var obj, obj1, arr1, mix;
        beforeEach(function() {
            obj = {
                a: {
                    b: {
                        c: "g"
                    }
                }
            }
            obj1 = {
                a: {
                    b: "cd"
                }
            }
            arr1 = [3, 4]
            mix = {
                b: "b",
                a: [3, {
                    a: 4
                }]

            }
        })

        it("can get all the path of object", function() {
            expect(collectionPath(obj1)).toEqual([

                ["a", "b"]
            ])
            expect(collectionPath(obj)).toEqual([

                ["a", "b", "c"]
            ])
        })
        it("can get all the path of array", function() {
            expect(collectionPath(arr1)).toEqual([
                [0],
                [1]
            ])
        })
        it("can get all the path of mix collection ", function() {
            expect(collectionPath(mix)).toEqual([
                ["b"],

                ["a", 0],

                ["a", 1, "a"]
            ])

        })
    })

});